<%@ tag import="com.biz.primus.base.tags.Layout" %>
<%@ tag import="com.google.common.base.Splitter" %>
<%@ tag import="com.google.common.collect.Lists" %>
<%@ tag import="java.util.Collections" %>
<%@taglib prefix="b" tagdir="/WEB-INF/tags/base" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--标题--%>
<%@ attribute name="title" required="true" type="java.lang.String" %>
<%--表单name--%>
<%@ attribute name="name" required="true" type="java.lang.String" %>
<%--表单id--%>
<%@ attribute name="id" required="false" type="java.lang.String" %>
<c:set var="id" value="${empty id ? name : id}"/>
<%--是否必填项--%>
<%@ attribute name="required" required="false" type="java.lang.Boolean" %>
<%--布局,只有single--%>
<c:set var="layout" value="<%=Layout.single%>"/>
<%--标题列宽--%>
<%@ attribute name="titleCol" required="false" type="java.lang.Integer" %>
<c:set var="titleCol" value="${empty titleCol? layout.titleCol:titleCol}"/>
<%--输入框列宽--%>
<%@ attribute name="inputCol" required="false" type="java.lang.Integer" %>
<c:set var="inputCol" value="${empty inputCol? (12-titleCol):inputCol}"/>

<%@attribute name="selectHeight" type="java.lang.Integer" required="false" %>
<c:set var="selectHeight" value="${empty selectHeight?270:selectHeight}"/>

<%@attribute name="data" type="com.biz.primus.base.tags.DualListboxData" required="true" %>

<b:label title="${title}" forId="${id}" titleCol="${titleCol}"/>
<b:row layout="${layout}">
    <div class="col-sm-${inputCol}">
        <div class="bootstrap-duallistbox-container row moveonselect">
            <div class="box1 col-md-6">
                <label for="${id}_nonselected" style="display: none;"></label>
                <span class="info-container">
                    <span class="info">${data.leftTitle}</span>
                    <button type="button" class="btn clear1 pull-right btn-default btn-xs btn-white btn-bold btn-info">展示全部</button>
                </span>
                <input class="filter form-control" type="text" placeholder="过滤后">
                <div class="btn-group buttons">
                    <button type="button" class="btn moveall btn-white btn-bold btn-info" title="移动全部">
                        <i class="fa fa-arrow-right"></i>
                        <i class="fa fa-arrow-right"></i>
                    </button>
                </div>
                <select multiple="multiple" id="${id}_nonselected" class="form-control" name="${name}_helper1" style="height: ${selectHeight}px;">
                    <c:forEach items="${data.items}" var="i">
                        <c:if test="${not i.selected}">
                            <option value="${i.value}">${i.text}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </div>
            <div class="box2 col-md-6">
                <label for="${id}_selected" style="display: none;"></label>
                <span class="info-container">
                <span class="info">${data.rightTitle}</span>
                <button type="button" class="btn clear2 pull-right btn-default btn-xs btn-white btn-bold btn-info">展示全部</button>   </span>
                <input class="filter form-control" type="text" placeholder="过滤后">
                <div class="btn-group buttons">
                    <button type="button" class="btn removeall btn-white btn-bold btn-info" title="移动全部">
                        <i class="fa fa-arrow-left"></i>
                        <i class="fa fa-arrow-left"></i>
                    </button>
                </div>
                <select multiple="multiple" id="${id}_selected" class="form-control" name="${name}_helper2" style="height: ${selectHeight}px;">
                    <c:forEach items="${data.items}" var="i">
                        <c:if test="${i.selected}">
                            <option value="${i.value}">${i.text}</option>
                        </c:if>
                    </c:forEach>
                </select>
            </div>
        </div>
        <select multiple="multiple" size="10" name="${name}" id="${id}" style="display: none;">
            <c:forEach items="${data.items}" var="i">
                <option value="${i.value}" <c:if test="${i.selected}">selected</c:if> >${i.text}</option>
            </c:forEach>
        </select>

        <div class="hr hr-16 hr-dotted"></div>
    </div>
</b:row>
